:root {
    --bg-color: #f0f2f5;
    --container-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #1f2937;
    --text-secondary: #6b7280;
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --input-bg: #f9fafb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 800px;
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.header { text-align: center; }
.header h1 { margin: 0; }
.header p { margin: 0.25rem 0 0; color: var(--text-secondary); }

.api-key-container { display: flex; align-items: center; gap: 0.5rem; }
.api-key-container label { font-weight: 500; }
.api-key-container input {
    flex-grow: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--input-bg);
}

.chat-container {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.input-area {
    display: flex;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
#prompt-input {
    flex-grow: 1;
    border: none;
    resize: none;
    padding: 0.5rem;
    font-size: 1rem;
    height: 80px;
    background: transparent;
}
#prompt-input:focus { outline: none; }

#send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    align-self: flex-end;
}
#send-btn:hover { background: var(--primary-hover); }
#send-btn:disabled { background: #9ca3af; cursor: not-allowed; }

.output-area {
    padding: 1rem;
    min-height: 200px;
    position: relative;
}

.markdown-body { line-height: 1.6; }
.markdown-body h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
    margin-top: 1.5em;
    margin-bottom: 1em;
}
.markdown-body p { margin: 0 0 1em; }
.placeholder { color: var(--text-secondary); }

.spinner {
    position: absolute;
    top: 1rem;
    right: 1rem;
    border: 3px solid rgba(0, 0, 0, 0.1);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
}
.hidden { display: none; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.error {
    color: #b91c1c;
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    margin-top: 1rem;
}
